﻿using System;
class ThirdBitInfo
{
    static void Main()
    {
        int testnumber;
        Console.Write("Input Number: ");
        while (true)
        {
            try
            {
                testnumber = int.Parse(Console.ReadLine());
                break;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + "\nPlease re-enter test number:");
            }
        }
        Console.WriteLine(Convert.ToString(testnumber, 2).PadLeft(32, '0'));
        bool isbitone = (((testnumber & (1 << 3)) >> 3) == 1);
        Console.WriteLine("the third bit is 1? {0}", isbitone);
        Console.ReadLine();
    }
}

